<template>
    <div class="app-container">
        <el-row>
            <el-col :span="24" class="card-box">
                <el-card>
                    <fileUpload :limit="100" :fileType="['zip','bin','fw','png', 'jpg', 'jpeg','doc', 'xls', 'ppt', 'txt', 'pdf']"></fileUpload>
                </el-card>
                <el-card style="margin-top: 10px;">
                    <template #header>
                        <div class="card-header">
                            <span>小程序审核开关</span>
                        </div>
                    </template>
                    <el-switch v-if="openValueId" :active-value="1" :inactive-value="0" v-model="openValue"  @change="handleupdateHideStatus"/>
                </el-card>
            </el-col>

        </el-row>
    </div>
</template>

<script setup name="ChartManage">
import { getCache } from '@/api/monitor/cache';
import { findHideStatus,updateHideStatus } from "@/api/api";

import fileUpload from "@/components/FileUpload/index.vue"

const cache = ref([]);
const { proxy } = getCurrentInstance();
const openValue = ref('')
const openValueId = ref('')

function getfindHideStatus () {
    findHideStatus().then((res)=>{
        // 0关闭，1开启
        openValue.value = res.data.type
        openValueId.value = res.data.id
    })
}
function handleupdateHideStatus () {
    let params = {
        id:openValueId.value,
        type:openValue.value,
    }
    updateHideStatus(params).then((res)=>{
        getfindHideStatus()
    })
}
function getList () {
    proxy.$modal.loading("正在加载数据，请稍候！");

    getCache().then(response => {
        proxy.$modal.closeLoading();
        cache.value = response.data;
    })
}
getfindHideStatus()
getList();
</script>
